<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        
    </style>
</head>
<body>
    <input type="text" id="username"><br>
    <input type="text" id="password"><br>
    <input type="checkbox" id="remember">记住账号密码
    <input type="button" id="btn" value="登录">
</body>
<script>
    
    const oun = document.getElementById("username");
    const opw = document.getElementById("password");
    const ormb = document.getElementById("remember");
    const obtn = document.getElementById("btn");

    // 获取数据，填充到表单
    oun.value = localStorage.getItem("username")
    opw.value = localStorage.getItem("password")
    
    // 优化成一条数据（利用对象）

    // 点击时
    obtn.onclick = function(){
        // 判断是否选中复选框
        if( ormb.checked ){
            // 存储用户信息到本地存储
            localStorage.setItem("username", oun.value)
            localStorage.setItem("password", opw.value)
        }
    }

</script>
</html>